package com.github.prontera.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.github.prontera.ApiVersion;
import com.github.prontera.domain.IssueAnswer;
import com.github.prontera.model.response.ObjectDataResponse;
import com.github.prontera.service.IssueAnswerService;
import com.github.prontera.util.Page;

import io.swagger.annotations.ApiOperation;


/**
 * 活动
 */
@RestController
@RequestMapping(value = ApiVersion.MANAGE_V1_PREFIX + "/issueAnswer", produces = { MediaType.APPLICATION_JSON_UTF8_VALUE }, consumes = { MediaType.APPLICATION_JSON_UTF8_VALUE })
public class IssueAnswerController{
	
	@Autowired
	private IssueAnswerService issueAnswerService;
	
	/**
	 * 查询视频列表
	 */
	
	@RequestMapping(value = "find", method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "查询视频列表" , notes = "查询视频列表")
	public ObjectDataResponse<Page<IssueAnswer>> find(@RequestBody IssueAnswer issueAnswer){
		issueAnswer.setOrderBy("I_ISSUE_ANSWER.create_time desc");
		Page<IssueAnswer> datas =issueAnswerService.page2(issueAnswer);
		return new ObjectDataResponse<Page<IssueAnswer>>(datas);
	}
	
	@ApiOperation(value = "删除视频", notes = "删除视频")
	@RequestMapping(value = "/deleteAnswer", method = RequestMethod.POST)
	@ResponseBody
	public ObjectDataResponse<Boolean> deleteAnswer(@RequestBody IssueAnswer issueAnswer) {
		issueAnswerService.remove(issueAnswer);
		return new ObjectDataResponse<Boolean>(true);
	}
	
	@ApiOperation(value = "查询视频详情", notes = "查询视频详情")
	@RequestMapping(value = "/getAnswer", method = RequestMethod.POST)
	@ResponseBody
	public ObjectDataResponse<IssueAnswer> getAnswer(@RequestBody IssueAnswer issueAnswer) {
		
		issueAnswer= issueAnswerService.get(issueAnswer.getId());
		return new ObjectDataResponse<IssueAnswer>(issueAnswer);
	}
}
